/**
 * 
 */
package com.tidux.commons.android.util;

import android.database.Cursor;

/**
 * CursorUtils
 * @author ren.tangr
 * 
 */
public class CursorUtils {

	//######### provide short operation of cursor get data #############
	static public String getString(String columnName, Cursor cursor) {
		if (cursor != null && columnName != null && columnName.length() != 0) {
			return cursor.getString(cursor.getColumnIndex(columnName));
		}
		return null;
	}

	static public byte[] getBlob(String columnName, Cursor cursor) {
		if (cursor != null && columnName != null && columnName.length() != 0) {
			return cursor.getBlob(cursor.getColumnIndex(columnName));
		}
		return null;
	}

	static public int getInt(String columnName, Cursor cursor) {
		if (cursor != null && columnName != null && columnName.length() != 0) {
			return cursor.getInt(cursor.getColumnIndex(columnName));
		}
		return 0;
	}

	static public double getDouble(String columnName, Cursor cursor) {
		if (cursor != null && columnName != null && columnName.length() != 0) {
			return cursor.getDouble(cursor.getColumnIndex(columnName));
		}
		return 0.0d;
	}

	static public float getFloat(String columnName, Cursor cursor) {
		if (cursor != null && columnName != null && columnName.length() != 0) {
			return cursor.getFloat(cursor.getColumnIndex(columnName));
		}
		return 0.0f;
	}

	static public short getShort(String columnName, Cursor cursor) {
		if (cursor != null && columnName != null && columnName.length() != 0) {
			return cursor.getShort(cursor.getColumnIndex(columnName));
		}
		return 0;
	}
	//######### provide short operation of cursor get data #############
	
}
